package com.xatime.auth.core.model;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Set;

/**
 * 实现oauth2的用户接口，并提供对应的方法
 * @author mason
 * @since 2018/11/6
 */
@Data
@NoArgsConstructor
public class User implements UserDetails {

    private String id;
    private String username;
    private String password;
    private Set<GrantedAuthority> authorities;
    private final boolean accountNonExpired = true;
    private final boolean accountNonLocked = true;
    private final boolean credentialsNonExpired = true;
    private final boolean enabled = true;

    public User(String id, String username, String password, Set<GrantedAuthority> authorities) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.authorities = authorities;
    }
}
